package com.qubuyer.core.app

import androidx.multidex.MultiDexApplication
import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.Gson
import com.hjq.toast.ToastUtils
import com.qubuyer.core.http.IHttpResult
import com.qubuyer.core.utils.AppUtil
import com.tencent.bugly.Bugly
import com.tencent.bugly.beta.Beta
import com.tencent.bugly.crashreport.CrashReport
import me.jessyan.autosize.AutoSizeConfig
import okhttp3.Interceptor

/**
 * Author: linwg
 * Time: 2020/12/9 0009
 * Description:
 */
abstract class BaseApplication : MultiDexApplication() {

    override fun onCreate() {
        super.onCreate()
        if (isDebug()) {
            ARouter.openLog()
            ARouter.openDebug()
        }
        ARouter.init(this)
//        val processName = AppUtil.getProcessName()
//        val strategy = CrashReport.UserStrategy(this)
//        strategy.isUploadProcess = processName == null || processName == packageName
//        Bugly.init(this, if (isDebug()) "6c82dd6531" else "eaf71f044e", isDebug(), strategy)
//        Beta.initDelay = 6000
        CrashReport.setIsDevelopmentDevice(this, isDebug())

        AutoSizeConfig.getInstance().isExcludeFontScale = true
        ToastUtils.init(this)
    }

    open fun isDebug(): Boolean {
        return true
    }

    abstract fun configBaseUrl(): String

    abstract fun interceptors(): List<Interceptor>

    abstract fun networkInterceptors(): List<Interceptor>

    open fun gson(): Gson? {
        return null
    }
}